#pragma once
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>
#include "MeshData.h"
class MeshSort
{
	typedef KBase K;
	typedef K::FT FT;
	typedef K::Triangle_3 CGAL_Triangle;
	typedef std::vector<CGAL_Triangle>::iterator Iterator;
	typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
	typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
	typedef CGAL::AABB_tree<AABB_triangle_traits> AABBTree;
public:
	MeshSort() {};
	MeshSort(const vector<MeshData>& vData)
	{
		UpdateTriangle(vData);
	}
	int GetHeight(double& z, double x, double y) const;
	void UpdateTriangle(const vector<MeshData>& vData);
	void Save(CFileSaveData& fp);
	void Save(string sFileName);
	void Load(CFileLoadData& fp);
	void Load(string sFileName);
private:
	shared_ptr<AABBTree> m_pTree;
	vector<CGAL_Triangle> m_vTriangles;
	double m_pntMin[3], m_pntMax[3] ;
};

